package com.sugar.psych.assessment.module.business.dal.mysql.userpsychassessmentrecord;

import java.util.*;

import com.sugar.psych.assessment.framework.common.pojo.PageResult;
import com.sugar.psych.assessment.framework.common.pojo.PageParam;
import com.sugar.psych.assessment.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.sugar.psych.assessment.framework.mybatis.core.mapper.BaseMapperX;
import com.sugar.psych.assessment.module.business.dal.dataobject.userpsychassessmentrecord.UserPsychQuestionRecordDO;
import com.sugar.psych.assessment.module.business.other.OptionListTypeHandler;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

/**
 * 用户心理测评题目表 Mapper
 *
 * @author Ysugar
 */
@Mapper
public interface UserPsychQuestionRecordMapper extends BaseMapperX<UserPsychQuestionRecordDO> {

    default PageResult<UserPsychQuestionRecordDO> selectPage(PageParam reqVO, Long recordId) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserPsychQuestionRecordDO>()
            .eq(UserPsychQuestionRecordDO::getRecordId, recordId)
            .orderByDesc(UserPsychQuestionRecordDO::getId));
    }

    default int deleteByRecordId(Long recordId) {
        return delete(UserPsychQuestionRecordDO::getRecordId, recordId);
    }

	default int deleteByRecordIds(List<Long> recordIds) {
	    return deleteBatch(UserPsychQuestionRecordDO::getRecordId, recordIds);
	}

    @Select("select * from business_user_psych_question_record bupqr where bupqr.record_id = #{param1}")
    @Results(@Result(column = "option_list", property = "optionList", typeHandler = OptionListTypeHandler.class))
    List<UserPsychQuestionRecordDO> selectListByRecordId(Long recordId);
}
